﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.ComponentModel;

namespace MiApp {
    public class Cuenta : DependencyObject, System.ComponentModel.INotifyPropertyChanged {

        private string usuario;
        public event PropertyChangedEventHandler PropertyChanged;
        private static readonly DependencyProperty montoProperty = DependencyProperty.Register("monto", typeof(double),typeof(Cuenta));



        public Cuenta() {
            usuario = "jose";
            monto = 200;
        }

        public  double monto {
            get { return (double)GetValue(montoProperty); }
            set { SetValue(montoProperty, value); }
        }

        public string Usuario {
            get { return usuario; }
            set { usuario = value;
             //   PropertyChanged(this,new PropertyChangedEventArgs("Usuario")); 
            }
        }

       
      
    }

    public class ValidacionMonto : System.Windows.Controls.ValidationRule {


        public override System.Windows.Controls.ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo) {

            double d = Double.Parse(value.ToString());
            if (d < 100) {
                return new System.Windows.Controls.ValidationResult(true, null);
            }else
                return new System.Windows.Controls.ValidationResult(false,"El monto es menor a 100!!!");
            }
    }

    public class Convert : System.Windows.Data.IValueConverter {

        object System.Windows.Data.IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
            double d =(double) value;
            return d.ToString("C");
        }

        object System.Windows.Data.IValueConverter.ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
            return Double.Parse(value.ToString());
        }
    }

    public class MiAdorno : System.Windows.Documents.Adorner {

        public MiAdorno(UIElement ui): base(ui) { 
        
        }

        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext) {
            base.OnRender(drawingContext);
            drawingContext.DrawEllipse(System.Windows.Media.Brushes.Red, new System.Windows.Media.Pen(System.Windows.Media.Brushes.Green, 5), new Point(0, 0), 20, 20);

        
        }
    
    }

    public class MiColeccion : System.Collections.ObjectModel.ObservableCollection<String> {

        public MiColeccion() {

            this.Add("jose");
            this.Add("miguel");
            this.Add("ssxx");

        }

    }

}
